package com.demo.my.Controller.detail;

import com.demo.my.Entity.Employee;
import com.demo.my.Service.EmployeeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.UUID;

@WebServlet("/toUpdate")
/**
 * 预处理
 * 可以扩展(指定）
 */
public class PreUpdateServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String vid = req.getParameter("vid");
        Employee infoById = EmployeeService.getInfoById(Integer.parseInt(vid));
        String uuid = UUID.randomUUID().toString();
        req.setAttribute("req_update_uuid",uuid);
        req.setAttribute("employee",infoById);
        req.getSession().setAttribute("sess_update_uuid",uuid);
        req.getRequestDispatcher("/jsp/admin/oneself_update.jsp").forward(req,resp);

    }
}
